<template>
  <view class="template-recharge-detail">
    <!-- 顶部自定义导航 -->
    <tn-nav-bar fixed alpha customBack>
      <view slot="back" class='tn-custom-nav-bar__back' @click="goBack">
        <text class='icon tn-icon-left'></text>
      </view>
    </tn-nav-bar>

    <!-- 页面内容 -->
    <view class="detail-content" :style="{ paddingTop: vuex_custom_bar_height + 'px' }">
      <!-- 明细列表 -->
      <view class="detail-list">
        <view class="detail-item tn-flex tn-flex-row-between" v-for="(item, index) in rechargeList" :key="index">
          <view class="item-left">
            <view class="title">{{ item.type }}</view>
            <view class="time tn-color-gray">{{ item.time }}</view>
          </view>
          <view class="item-right">
            <view class="amount" :class="{'income': item.amount > 0}">
              {{ item.amount > 0 ? '+' : '' }}{{ item.amount }}欢币
            </view>
            <view class="status tn-color-gray">{{ item.status }}</view>
          </view>
        </view>
      </view>

      <!-- 无数据提示 -->
      <view class="no-data tn-flex tn-flex-direction-column tn-flex-col-center" v-if="rechargeList.length === 0">
        <text class="tn-icon-info-fill"></text>
        <text class="tips">暂无充值记录</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'RechargeDetail',
  data() {
    return {
      rechargeList: [
        {
          type: '余粮充值',
          time: '2024-03-20 15:30:25',
          amount: 100,
          status: '充值成功'
        },
        {
          type: '余粮消费',
          time: '2024-03-19 10:20:15',
          amount: -50,
          status: '交易成功'
        },
        {
          type: '余粮充值',
          time: '2024-03-18 09:15:30',
          amount: 200,
          status: '充值成功'
        }
      ]
    }
  },
  computed: {
    vuex_custom_bar_height() {
      return uni.getSystemInfoSync().statusBarHeight + 45
    }
  },
  methods: {
    goBack() {
      uni.navigateBack({
        delta: 1
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.template-recharge-detail {
  min-height: 100vh;
  background-color: #f8f8f8;
}

.detail-content {
  padding: 30rpx;
}

.detail-list {
  background-color: #FFFFFF;
  border-radius: 20rpx;
  padding: 0 30rpx;
  
  .detail-item {
    padding: 30rpx 0;
    border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);
    
    &:last-child {
      border-bottom: none;
    }
    
    .item-left {
      .title {
        font-size: 30rpx;
        margin-bottom: 10rpx;
      }
      
      .time {
        font-size: 24rpx;
      }
    }
    
    .item-right {
      text-align: right;
      
      .amount {
        font-size: 32rpx;
        font-weight: bold;
        color: #FF8155;
        margin-bottom: 10rpx;
        
        &.income {
          color: #19be6b;
        }
      }
      
      .status {
        font-size: 24rpx;
      }
    }
  }
}

.no-data {
  padding: 100rpx 0;
  color: #999;
  
  .tn-icon-info-fill {
    font-size: 120rpx;
    margin-bottom: 20rpx;
  }
  
  .tips {
    font-size: 28rpx;
  }
}

/* 导航栏返回按钮样式 */
.tn-custom-nav-bar__back {
  width: auto;
  height: auto;
  position: relative;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-left: 30rpx;
  
  .icon {
    font-size: 46rpx;
    color: #000000;
    
    &:active {
      transform: scale(0.92);
    }
  }
}
</style> 